package com.dao.impl;

import com.Bean.RoomRate;
import com.Bean.RoomType;
import com.dao.RoomRateDao;
import com.dao.RoomTypeDao;
import com.util.JdbcUtil;
import com.util.PageUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RoomRateDaoImpl implements RoomRateDao {
    @Override
    public PageUtil<RoomRate> queryDataBypage(int currentPgae, int pageSize, RoomRate t) throws IllegalAccessException, SQLException, InstantiationException {
        String sql = "SELECT rtid,rname,wkprice,weprice FROM room" ;
        ArrayList values = new ArrayList();


        return JdbcUtil.queryDataByPage(sql, RoomRate.class, currentPgae, pageSize, values.toArray());
    }

    @Override
    public int insert(RoomRate roomRate) throws SQLException {
        return 0;
    }

    @Override
    public List<RoomRate> queryData(RoomRate roomRate) throws IllegalAccessException, SQLException, InstantiationException {
        return null;
    }

    @Override
    public int update(RoomRate roomRate) throws SQLException {
        String sql = "UPDATE `room` SET rname=?,wkprice=?,weprice=? WHERE rtid=?";
        return JdbcUtil.insertOrUpdateOrDelete(sql,new Object[]{
                roomRate.getRname(),roomRate.getWkprice(),roomRate.getWeprice(),roomRate.getRtid()
        });
    }

    @Override
    public int deleteById(Object id) throws SQLException {
        return 0;
    }
}
